﻿using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;

#nullable disable

namespace lin_cms_dotnet_core.Models
{
    public partial class lincmsContext : DbContext
    {
        public lincmsContext()
        {
        }

        public lincmsContext(DbContextOptions<lincmsContext> options)
            : base(options)
        {
        }

        public virtual DbSet<Book> Books { get; set; }
        public virtual DbSet<Flow> Flows { get; set; }
        public virtual DbSet<LinFile> LinFiles { get; set; }
        public virtual DbSet<LinGroup> LinGroups { get; set; }
        public virtual DbSet<LinGroupPermission> LinGroupPermissions { get; set; }
        public virtual DbSet<LinLog> LinLogs { get; set; }
        public virtual DbSet<LinPermission> LinPermissions { get; set; }
        public virtual DbSet<LinUser> LinUsers { get; set; }
        public virtual DbSet<LinUserGroup> LinUserGroups { get; set; }
        public virtual DbSet<LinUserIdentity> LinUserIdentities { get; set; }
        public virtual DbSet<Movie> Movies { get; set; }
        public virtual DbSet<Music> Musics { get; set; }
        public virtual DbSet<Sentence> Sentences { get; set; }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            if (!optionsBuilder.IsConfigured)
            {
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see http://go.microsoft.com/fwlink/?LinkId=723263.
                optionsBuilder.UseMySql("server=localhost;user=root;password=root;database=lin-cms", Microsoft.EntityFrameworkCore.ServerVersion.Parse("10.1.37-mariadb"));
            }
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.HasCharSet("utf8mb4")
                .UseCollation("utf8mb4_general_ci");

            modelBuilder.Entity<Book>(entity =>
            {
                entity.ToTable("book");

                entity.Property(e => e.Id)
                    .HasColumnType("int(11)")
                    .HasColumnName("id");

                entity.Property(e => e.Author)
                    .HasMaxLength(30)
                    .HasColumnName("author");

                entity.Property(e => e.CreateTime)
                    .HasColumnType("datetime(3)")
                    .HasColumnName("create_time")
                    .HasDefaultValueSql("CURRENT_TIMESTAMP(3)");

                entity.Property(e => e.DeleteTime)
                    .HasColumnType("datetime(3)")
                    .HasColumnName("delete_time");

                entity.Property(e => e.Image)
                    .HasMaxLength(100)
                    .HasColumnName("image");

                entity.Property(e => e.Summary)
                    .HasMaxLength(1000)
                    .HasColumnName("summary");

                entity.Property(e => e.Title)
                    .IsRequired()
                    .HasMaxLength(50)
                    .HasColumnName("title");

                entity.Property(e => e.UpdateTime)
                    .HasColumnType("datetime(3)")
                    .ValueGeneratedOnAddOrUpdate()
                    .HasColumnName("update_time")
                    .HasDefaultValueSql("CURRENT_TIMESTAMP(3)");
            });

            modelBuilder.Entity<Flow>(entity =>
            {
                entity.ToTable("flow");

                entity.UseCollation("utf8mb4_bin");

                entity.Property(e => e.Id)
                    .HasColumnType("int(11)")
                    .HasColumnName("id");

                entity.Property(e => e.ArtId)
                    .HasColumnType("int(11)")
                    .HasColumnName("art_id");

                entity.Property(e => e.CreatedAt)
                    .HasColumnType("datetime")
                    .HasColumnName("created_at");

                entity.Property(e => e.DeletedAt)
                    .HasColumnType("datetime")
                    .HasColumnName("deleted_at");

                entity.Property(e => e.Index)
                    .HasColumnType("int(11)")
                    .HasColumnName("index");

                entity.Property(e => e.Status)
                    .HasColumnType("smallint(6)")
                    .HasColumnName("status");

                entity.Property(e => e.Type)
                    .HasColumnType("int(11)")
                    .HasColumnName("type");

                entity.Property(e => e.UpdatedAt)
                    .HasColumnType("datetime")
                    .HasColumnName("updated_at");
            });

            modelBuilder.Entity<LinFile>(entity =>
            {
                entity.ToTable("lin_file");

                entity.HasIndex(e => new { e.Md5, e.DeleteTime }, "md5_del")
                    .IsUnique();

                entity.Property(e => e.Id)
                    .HasColumnType("int(10) unsigned")
                    .HasColumnName("id");

                entity.Property(e => e.CreateTime)
                    .HasColumnType("datetime(3)")
                    .HasColumnName("create_time")
                    .HasDefaultValueSql("CURRENT_TIMESTAMP(3)");

                entity.Property(e => e.DeleteTime)
                    .HasColumnType("datetime(3)")
                    .HasColumnName("delete_time");

                entity.Property(e => e.Extension)
                    .HasMaxLength(50)
                    .HasColumnName("extension");

                entity.Property(e => e.Md5)
                    .HasMaxLength(40)
                    .HasColumnName("md5")
                    .HasComment("md5值，防止上传重复文件");

                entity.Property(e => e.Name)
                    .IsRequired()
                    .HasMaxLength(100)
                    .HasColumnName("name");

                entity.Property(e => e.Path)
                    .IsRequired()
                    .HasMaxLength(500)
                    .HasColumnName("path");

                entity.Property(e => e.Size)
                    .HasColumnType("int(11)")
                    .HasColumnName("size");

                entity.Property(e => e.Type)
                    .IsRequired()
                    .HasMaxLength(10)
                    .HasColumnName("type")
                    .HasDefaultValueSql("'LOCAL'")
                    .HasComment("LOCAL 本地，REMOTE 远程");

                entity.Property(e => e.UpdateTime)
                    .HasColumnType("datetime(3)")
                    .ValueGeneratedOnAddOrUpdate()
                    .HasColumnName("update_time")
                    .HasDefaultValueSql("CURRENT_TIMESTAMP(3)");
            });

            modelBuilder.Entity<LinGroup>(entity =>
            {
                entity.ToTable("lin_group");

                entity.HasIndex(e => new { e.Name, e.DeleteTime }, "name_del")
                    .IsUnique();

                entity.Property(e => e.Id)
                    .HasColumnType("int(10) unsigned")
                    .HasColumnName("id");

                entity.Property(e => e.CreateTime)
                    .HasColumnType("datetime(3)")
                    .HasColumnName("create_time")
                    .HasDefaultValueSql("CURRENT_TIMESTAMP(3)");

                entity.Property(e => e.DeleteTime)
                    .HasColumnType("datetime(3)")
                    .HasColumnName("delete_time");

                entity.Property(e => e.Info)
                    .HasMaxLength(255)
                    .HasColumnName("info")
                    .HasComment("分组信息：例如：搬砖的人");

                entity.Property(e => e.Level)
                    .HasColumnType("tinyint(2)")
                    .HasColumnName("level")
                    .HasDefaultValueSql("'3'")
                    .HasComment("分组级别 1：root 2：guest 3：user（root、guest分组只能存在一个)");

                entity.Property(e => e.Name)
                    .IsRequired()
                    .HasMaxLength(60)
                    .HasColumnName("name")
                    .HasComment("分组名称，例如：搬砖者");

                entity.Property(e => e.UpdateTime)
                    .HasColumnType("datetime(3)")
                    .ValueGeneratedOnAddOrUpdate()
                    .HasColumnName("update_time")
                    .HasDefaultValueSql("CURRENT_TIMESTAMP(3)");
            });

            modelBuilder.Entity<LinGroupPermission>(entity =>
            {
                entity.ToTable("lin_group_permission");

                entity.HasIndex(e => new { e.GroupId, e.PermissionId }, "group_id_permission_id");

                entity.Property(e => e.Id)
                    .HasColumnType("int(10) unsigned")
                    .HasColumnName("id");

                entity.Property(e => e.GroupId)
                    .HasColumnType("int(10) unsigned")
                    .HasColumnName("group_id")
                    .HasComment("分组id");

                entity.Property(e => e.PermissionId)
                    .HasColumnType("int(10) unsigned")
                    .HasColumnName("permission_id")
                    .HasComment("权限id");
            });

            modelBuilder.Entity<LinLog>(entity =>
            {
                entity.ToTable("lin_log");

                entity.Property(e => e.Id)
                    .HasColumnType("int(10) unsigned")
                    .HasColumnName("id");

                entity.Property(e => e.CreateTime)
                    .HasColumnType("datetime(3)")
                    .HasColumnName("create_time")
                    .HasDefaultValueSql("CURRENT_TIMESTAMP(3)");

                entity.Property(e => e.DeleteTime)
                    .HasColumnType("datetime(3)")
                    .HasColumnName("delete_time");

                entity.Property(e => e.Message)
                    .HasMaxLength(450)
                    .HasColumnName("message");

                entity.Property(e => e.Method)
                    .HasMaxLength(20)
                    .HasColumnName("method");

                entity.Property(e => e.Path)
                    .HasMaxLength(50)
                    .HasColumnName("path");

                entity.Property(e => e.Permission)
                    .HasMaxLength(100)
                    .HasColumnName("permission");

                entity.Property(e => e.StatusCode)
                    .HasColumnType("int(11)")
                    .HasColumnName("status_code");

                entity.Property(e => e.UpdateTime)
                    .HasColumnType("datetime(3)")
                    .ValueGeneratedOnAddOrUpdate()
                    .HasColumnName("update_time")
                    .HasDefaultValueSql("CURRENT_TIMESTAMP(3)");

                entity.Property(e => e.UserId)
                    .HasColumnType("int(10) unsigned")
                    .HasColumnName("user_id");

                entity.Property(e => e.Username)
                    .HasMaxLength(24)
                    .HasColumnName("username");
            });

            modelBuilder.Entity<LinPermission>(entity =>
            {
                entity.ToTable("lin_permission");

                entity.Property(e => e.Id)
                    .HasColumnType("int(10) unsigned")
                    .HasColumnName("id");

                entity.Property(e => e.CreateTime)
                    .HasColumnType("datetime(3)")
                    .HasColumnName("create_time")
                    .HasDefaultValueSql("CURRENT_TIMESTAMP(3)");

                entity.Property(e => e.DeleteTime)
                    .HasColumnType("datetime(3)")
                    .HasColumnName("delete_time");

                entity.Property(e => e.Module)
                    .IsRequired()
                    .HasMaxLength(50)
                    .HasColumnName("module")
                    .HasComment("权限所属模块，例如：人员管理");

                entity.Property(e => e.Mount)
                    .IsRequired()
                    .HasColumnName("mount")
                    .HasDefaultValueSql("'1'")
                    .HasComment("0：关闭 1：开启");

                entity.Property(e => e.Name)
                    .IsRequired()
                    .HasMaxLength(60)
                    .HasColumnName("name")
                    .HasComment("权限名称，例如：访问首页");

                entity.Property(e => e.UpdateTime)
                    .HasColumnType("datetime(3)")
                    .ValueGeneratedOnAddOrUpdate()
                    .HasColumnName("update_time")
                    .HasDefaultValueSql("CURRENT_TIMESTAMP(3)");
            });

            modelBuilder.Entity<LinUser>(entity =>
            {
                entity.ToTable("lin_user");

                entity.HasIndex(e => new { e.Email, e.DeleteTime }, "email_del")
                    .IsUnique();

                entity.HasIndex(e => new { e.Username, e.DeleteTime }, "username_del")
                    .IsUnique();

                entity.Property(e => e.Id)
                    .HasColumnType("int(10) unsigned")
                    .HasColumnName("id");

                entity.Property(e => e.Avatar)
                    .HasMaxLength(500)
                    .HasColumnName("avatar")
                    .HasComment("头像url");

                entity.Property(e => e.CreateTime)
                    .HasColumnType("datetime(3)")
                    .HasColumnName("create_time")
                    .HasDefaultValueSql("CURRENT_TIMESTAMP(3)");

                entity.Property(e => e.DeleteTime)
                    .HasColumnType("datetime(3)")
                    .HasColumnName("delete_time");

                entity.Property(e => e.Email)
                    .HasMaxLength(100)
                    .HasColumnName("email")
                    .HasComment("邮箱");

                entity.Property(e => e.Nickname)
                    .HasMaxLength(24)
                    .HasColumnName("nickname")
                    .HasComment("用户昵称");

                entity.Property(e => e.UpdateTime)
                    .HasColumnType("datetime(3)")
                    .ValueGeneratedOnAddOrUpdate()
                    .HasColumnName("update_time")
                    .HasDefaultValueSql("CURRENT_TIMESTAMP(3)");

                entity.Property(e => e.Username)
                    .IsRequired()
                    .HasMaxLength(24)
                    .HasColumnName("username")
                    .HasComment("用户名，唯一");
            });

            modelBuilder.Entity<LinUserGroup>(entity =>
            {
                entity.ToTable("lin_user_group");

                entity.HasIndex(e => new { e.UserId, e.GroupId }, "user_id_group_id");

                entity.Property(e => e.Id)
                    .HasColumnType("int(10) unsigned")
                    .HasColumnName("id");

                entity.Property(e => e.GroupId)
                    .HasColumnType("int(10) unsigned")
                    .HasColumnName("group_id")
                    .HasComment("分组id");

                entity.Property(e => e.UserId)
                    .HasColumnType("int(10) unsigned")
                    .HasColumnName("user_id")
                    .HasComment("用户id");
            });

            modelBuilder.Entity<LinUserIdentity>(entity =>
            {
                entity.ToTable("lin_user_identity");

                entity.Property(e => e.Id)
                    .HasColumnType("int(10) unsigned")
                    .HasColumnName("id");

                entity.Property(e => e.CreateTime)
                    .HasColumnType("datetime(3)")
                    .HasColumnName("create_time")
                    .HasDefaultValueSql("CURRENT_TIMESTAMP(3)");

                entity.Property(e => e.Credential)
                    .HasMaxLength(100)
                    .HasColumnName("credential");

                entity.Property(e => e.DeleteTime)
                    .HasColumnType("datetime(3)")
                    .HasColumnName("delete_time");

                entity.Property(e => e.Identifier)
                    .HasMaxLength(100)
                    .HasColumnName("identifier");

                entity.Property(e => e.IdentityType)
                    .IsRequired()
                    .HasMaxLength(100)
                    .HasColumnName("identity_type");

                entity.Property(e => e.UpdateTime)
                    .HasColumnType("datetime(3)")
                    .ValueGeneratedOnAddOrUpdate()
                    .HasColumnName("update_time")
                    .HasDefaultValueSql("CURRENT_TIMESTAMP(3)");

                entity.Property(e => e.UserId)
                    .HasColumnType("int(10) unsigned")
                    .HasColumnName("user_id")
                    .HasComment("用户id");
            });

            modelBuilder.Entity<Movie>(entity =>
            {
                entity.ToTable("movie");

                entity.Property(e => e.Id)
                    .HasColumnType("int(11)")
                    .HasColumnName("id");

                entity.Property(e => e.Content)
                    .HasMaxLength(300)
                    .HasColumnName("content");

                entity.Property(e => e.CreatedAt)
                    .HasColumnType("datetime")
                    .HasColumnName("created_at");

                entity.Property(e => e.DeletedAt)
                    .HasColumnType("datetime")
                    .HasColumnName("deleted_at");

                entity.Property(e => e.FavNums)
                    .HasColumnType("smallint(6)")
                    .HasColumnName("fav_nums");

                entity.Property(e => e.Image)
                    .HasMaxLength(64)
                    .HasColumnName("image");

                entity.Property(e => e.Pubdate)
                    .HasColumnType("date")
                    .HasColumnName("pubdate");

                entity.Property(e => e.Status)
                    .HasColumnType("smallint(6)")
                    .HasColumnName("status");

                entity.Property(e => e.Title)
                    .HasMaxLength(50)
                    .HasColumnName("title");

                entity.Property(e => e.Type)
                    .HasColumnType("int(11)")
                    .HasColumnName("type");

                entity.Property(e => e.UpdatedAt)
                    .HasColumnType("datetime")
                    .HasColumnName("updated_at");
            });

            modelBuilder.Entity<Music>(entity =>
            {
                entity.ToTable("music");

                entity.Property(e => e.Id)
                    .HasColumnType("int(11)")
                    .HasColumnName("id");

                entity.Property(e => e.Content)
                    .HasMaxLength(300)
                    .HasColumnName("content");

                entity.Property(e => e.CreatedAt)
                    .HasColumnType("datetime")
                    .HasColumnName("created_at");

                entity.Property(e => e.DeletedAt)
                    .HasColumnType("datetime")
                    .HasColumnName("deleted_at");

                entity.Property(e => e.FavNums)
                    .HasColumnType("smallint(6)")
                    .HasColumnName("fav_nums");

                entity.Property(e => e.Image)
                    .HasMaxLength(64)
                    .HasColumnName("image");

                entity.Property(e => e.Pubdate)
                    .HasColumnType("date")
                    .HasColumnName("pubdate");

                entity.Property(e => e.Status)
                    .HasColumnType("smallint(6)")
                    .HasColumnName("status");

                entity.Property(e => e.Test)
                    .HasMaxLength(255)
                    .HasColumnName("test");

                entity.Property(e => e.Title)
                    .HasMaxLength(50)
                    .HasColumnName("title");

                entity.Property(e => e.Type)
                    .HasColumnType("int(11)")
                    .HasColumnName("type");

                entity.Property(e => e.UpdatedAt)
                    .HasColumnType("datetime")
                    .HasColumnName("updated_at");

                entity.Property(e => e.Url)
                    .HasMaxLength(100)
                    .HasColumnName("url");
            });

            modelBuilder.Entity<Sentence>(entity =>
            {
                entity.ToTable("sentence");

                entity.Property(e => e.Id)
                    .HasColumnType("int(11)")
                    .HasColumnName("id");

                entity.Property(e => e.Content)
                    .HasMaxLength(300)
                    .HasColumnName("content");

                entity.Property(e => e.CreatedAt)
                    .HasColumnType("datetime")
                    .HasColumnName("created_at");

                entity.Property(e => e.DeletedAt)
                    .HasColumnType("datetime")
                    .HasColumnName("deleted_at");

                entity.Property(e => e.FavNums)
                    .HasColumnType("smallint(6)")
                    .HasColumnName("fav_nums");

                entity.Property(e => e.Image)
                    .HasMaxLength(64)
                    .HasColumnName("image");

                entity.Property(e => e.Pubdate)
                    .HasColumnType("date")
                    .HasColumnName("pubdate");

                entity.Property(e => e.Status)
                    .HasColumnType("smallint(6)")
                    .HasColumnName("status");

                entity.Property(e => e.Title)
                    .HasMaxLength(50)
                    .HasColumnName("title");

                entity.Property(e => e.Type)
                    .HasColumnType("int(11)")
                    .HasColumnName("type");

                entity.Property(e => e.UpdatedAt)
                    .HasColumnType("datetime")
                    .HasColumnName("updated_at");
            });

            OnModelCreatingPartial(modelBuilder);
        }

        partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
    }
}
